//删除组件
import React from 'react'
import { Modal, Button } from 'antd';
export default function Buttons(props) {
  //对话框
  const App = () => {
    const [visible, setVisible] = React.useState(false);
    const [confirmLoading, setConfirmLoading] = React.useState(false);
    const [modalText, setModalText] = React.useState('你确定要删除嘛');

    const showModal = () => {
      setVisible(true);
    };

    const handleOk = () => {
      setModalText('你确定要删除嘛');
      setConfirmLoading(true);
      setTimeout(() => {
        setVisible(false);
        setConfirmLoading(false);
      }, 1000);
    };

    const handleCancel = () => {
      console.log('取消');
      setVisible(false);
    };


    //接受参数
    const { ccc } = props;
    let cc = (e) => {
      // console.log(Number((e.target.parentNode.parentNode.parentNode.firstChild.nextSibling).innerText));
      console.log(Number((e.target.parentNode.parentNode.parentNode.firstChild.nextSibling.nextSibling).innerText));
      setTimeout(() => {
        ccc(Number((e.target.parentNode.parentNode.parentNode.firstChild.nextSibling.nextSibling).innerText));
      }, 4000);
    }
    return (
      <>
        <Button type="primary" danger onClick={(e) => { showModal(); cc(e) }}>
          删除
        </Button>
        <Modal
          title="Title"
          visible={visible}
          onOk={handleOk}
          confirmLoading={confirmLoading}
          onCancel={handleCancel}
        >
          <p>{modalText}</p>
        </Modal>
      </>
    );
  };

  return (
    <App />
  )
}
